package com.example.lwj.FragmentDemo;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.example.lwj.zhangtianchengnews.R;

import java.util.ArrayList;

/**
 * Created by lwj on 2016/11/2.
 */
public class MenuFragment extends Fragment {
    private ListView listView;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.menu_layout, container, false);
        listView = (ListView) view.findViewById(R.id.lv);
        return view;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        ArrayList<String> strList = new ArrayList<String>();
        for (int i = 0; i < 10; i++) {
            strList.add("第" + i + "个条目");
        }
        // 设置数据适配器
        listView.setAdapter(new ArrayAdapter<String>(getActivity(),
                android.R.layout.simple_list_item_1, strList));
    }

}
